
# generate figure 5

library(rio) # to load data
library(tidyverse) # to reshape data
library(zoo) # to work with dates
library(scales) # to make nice axis breaks
library(cowplot) # to arrange plots as grids

# set your working directory
setwd("~/replication_files")


import("data/interest_rates.csv") %>%
  group_by(year) %>%
  summarize(mean_interest_official = mean(interest_official_creditors_ids, na.rm = T),
            mean_interest_private = mean(interest_private_creditors_ids, na.rm = T)) %>%
  pivot_longer(cols = c(mean_interest_official,mean_interest_private), names_to = "variable", values_to = "value") %>%
  mutate(variable = ifelse(variable == "mean_interest_official", "Official Creditors","Private Creditors")) %>%
  ggplot(aes(x = year, y = value, linetype = variable)) + geom_line() + theme_classic() + 
  labs(x = "Year", y = "Interest (%)", linetype = NULL)

ggsave("figures/figure5.pdf", height = 4, width = 7)
